<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="btn">add</div>
        <input type="button" value="btn" id="btn1">
        <input type="button" value="btn" id="btn2">
        <input type="button" value="btn" id="btn3">
        <input type="button" value="btn" id="btn4">
        <input type="button" value="btn" id="btn5">
        <p>111</p>
        <input type="button" value="btn" id="btn6">
        <input type="button" value="btn" id="btn7">
        <input type="button" value="btn" id="btn8">
        <input type="button" value="btn" id="btn9">
        <input type="button" value="btn" id="btn10">
        <p class="btn">add</p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <p class="btn"></p>
        <script src="./02_memory.js"></script>
        <script>
            var tmpEle

            function fn() {
                var ul = document.createElement('ul')
                for(var i=0; i<10; i++){
                    var li = document.createElement('li')
                    ul.appendChild(li)
                }
                tmpEle = ul

                tmpEle = null
            }
            document.getElementById('btn').addEventListener('click',fn)
        </script>
        <script>
            function foo(){
                var el = document.getElementById('btn')  //DOM已经存在在body中，el存储DOM  当删除Body中DOM，el还存在关于dom的引用 GC无法回收
                el.onclick = function(){
                    console.log(el.id)
                }

                el = null  //主动释放对DOM的引用
            }
            const oP = document.getElementById('p')
            for(var i=0; i<3; i++){
                var nP = document.cloneNode(false)
                nP.innerHTML = i
                // document.body.appendChild(oP)
                fragEle.appendChild(fragEle)
            }
            document.body.appendChild(nP)
            
           
        </script>
</body>
</html>